﻿
Public Class jsrnd
    Public Const functionName As String = "rnd"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing)
        inlineScript.addscript("rnd", "rnd.seed=(new Date()).getTime();" + _
                                      "function " + functionName + "()" + _
                                      "{rnd.seed=(rnd.seed*9301+49297)%233280;return rnd.seed/(233280.0);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If
        actionTarget += functionName + "()"
        Return actionTarget
    End Function
End Class
